﻿using System;
using System.Collections.Generic;
using System.Text;

namespace PortDetection
{
    class Profile
    {
        /// <summary>
        /// 加载配置文件
        /// </summary>
        public static void LoadProfile()
        {
            string strPath = AppDomain.CurrentDomain.BaseDirectory;
            _file = new IniFile(strPath + "Config.ini");
            UDPPort = Convert.ToInt32(_file.ReadString("Connect", " UdpPort", "-1"));    //读数据，下同
            RemoteIP = _file.ReadString("Connect", " RemoteIP", "");    //读数据，下同
            RemotePort = Convert.ToInt32(_file.ReadString("Connect", " RemotePort", "-1"));    //读数据，下同
            ShikePath = _file.ReadString("ServerPath", "SHIKE", "");    //读数据，下同
            AlarmServrPath = _file.ReadString("ServerPath", "AlarmServr", "");    //读数据，下同
            VideoServerPath = _file.ReadString("ServerPath", " VideoServer", "");    //读数据，下同
            NginxPath = _file.ReadString("ServerPath", " Nginx", "");    //读数据，下同
            EmailAddress = _file.ReadString("NoticeInfo", " EmailAddress", "2671283711@qq.com");    //读数据，下同
            Identification = _file.ReadString("NoticeInfo", " Identification", "huqwhvlgaanxebei");    //读数据，下同
        }

        /// <summary>
        /// 保存配置文件
        /// </summary>
        public static void SaveProfile()
        {
            string strPath = AppDomain.CurrentDomain.BaseDirectory;
            _file = new IniFile(strPath + "Config.ini");
            _file.WriteString("Connect", "UdpPort", UDPPort.ToString());            //写数据，下同
            _file.WriteString("Connect", "RemoteIP", RemoteIP);            //写数据，下同
            _file.WriteString("Connect", "RemotePort", RemotePort.ToString());            //写数据，下同
            _file.WriteString("ServerPath", "SHIKE", ShikePath);            //写数据，下同
            _file.WriteString("ServerPath", "AlarmServr", AlarmServrPath);            //写数据，下同
            _file.WriteString("ServerPath", "VideoServer", VideoServerPath);            //写数据，下同
            _file.WriteString("ServerPath", "Nginx", NginxPath);            //写数据，下同
            _file.WriteString("NoticeInfo", "EmailAddress", EmailAddress);            //写数据，下同
            _file.WriteString("NoticeInfo", "Identification", Identification);            //写数据，下同
        }

        private static IniFile _file;//内置了一个对象

        /// <summary>
        /// UDP通讯端口
        /// </summary>
        public static int UDPPort = -1;
        /// <summary>
        /// 远端IP
        /// </summary>
        public static string RemoteIP = "";
        /// <summary>
        /// 远端端口
        /// </summary>
        public static int RemotePort = -1;
        /// <summary>
        /// 接警服务器路径
        /// </summary>
        public static string ShikePath = "";
        /// <summary>
        /// 转警服务器路径
        /// </summary>
        public static string AlarmServrPath = "";
        /// <summary>
        /// 视频转发服务器路径
        /// </summary>
        public static string VideoServerPath = "";
        /// <summary>
        /// nginx路径
        /// </summary>
        public static string NginxPath = "";
        /// <summary>
        /// Email服务器地址
        /// </summary>
        public static string EmailAddress = "";
        /// <summary>
        /// Email服务标识
        /// </summary>
        public static string Identification = "";


    }
}
